using BCW;
using UnityEngine;

public class SelectableButtonTransport : SelectableButton
{
	[SerializeField]
	private UILabel lable;

	[SerializeField]
	private GameModeSelectUI controllerPanel;

	[SerializeField]
	private UIBasicSprite picture;

	private Product _transportProduct;

	private GameModesUI.TransportType _transportType;

	private MarketMiniProductInfo _transportInfoPanel;

	private SelectTransportUI _selectTransportController;

	public UIBasicSprite Picture
	{
		get
		{
			return picture;
		}
	}

	public Product TransportProduct
	{
		get
		{
			return _transportProduct;
		}
		set
		{
			_transportProduct = value;
		}
	}

	public GameModesUI.TransportType TransportType
	{
		get
		{
			return _transportType;
		}
		set
		{
			_transportType = value;
		}
	}

	public MarketMiniProductInfo TransportInfoPanel
	{
		get
		{
			return _transportInfoPanel;
		}
		set
		{
			_transportInfoPanel = value;
		}
	}

	public SelectTransportUI SelectTransportController
	{
		get
		{
			return _selectTransportController;
		}
		set
		{
			_selectTransportController = value;
		}
	}

	public override void Select(bool select)
	{
		if (select && !selected)
		{
			SetBottomPanelInfo();
			SetTransportToSetting();
			UnselectBoughtShopButton();
		}
		base.Select(select);
	}

	public override void OnClick()
	{
		if (selected)
		{
			controllerPanel.Play();
		}
		else
		{
			base.OnClick();
		}
	}

	public void SetName(string name)
	{
		lable.text = name;
	}

	public void SetTexture(Texture2D texture)
	{
		picture = picture.ReplaceForCurrentPlatform();
		picture.mainTexture = texture;
	}

	public void LoadAndSetTexture(string path, string id)
	{
		picture = picture.ReplaceForCurrentPlatform();
		picture.LoadTextureAndAlphaMask(path, id);
	}

	private void SetBottomPanelInfo()
	{
		TransportInfoPanel.Product = TransportProduct;
		TransportInfoPanel.ShowMiniInfoPanel();
	}

	private void SetTransportToSetting()
	{
		settings.SetSelectedTransportName(TransportType, TransportProduct.id);
	}

	private void UnselectBoughtShopButton()
	{
		if (!(_selectTransportController == null) && !(_selectTransportController.BoughtShopButton == null))
		{
			_selectTransportController.BoughtShopButton.Unequip();
		}
	}
}
